package com.sc.nft.task;

import com.sc.nft.service.MallActivityShareTeamService;
import com.sc.nft.service.MallShareTeamOrderService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author liGen
 * @version 1.0
 * @date 2023/12/20 5:53 下午
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class MallActivityShareTask {

    private final MallActivityShareTeamService mallActivityShareTeamService;
    private final MallShareTeamOrderService mallShareTeamOrderService;

    /**
     * 分享活动团队收益结算
     */
    @XxlJob("shareTeamIncomeSettlement")
    public void shareTeamIncomeSettlement() {
        mallActivityShareTeamService.getListByShareStatus().forEach(mallActivityShareTeam -> {
            try {
                mallShareTeamOrderService.shareTeamIncomeSettlement(mallActivityShareTeam);
            } catch (Exception e) {
                log.error("分享活动团队收益结算失败 异常 teamId:{}", mallActivityShareTeam.getId(), e);
            }
        });
    }
}
